<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<%-- <script src="<%=request.getContextPath()%>/ui/js/paginate.js"></script> --%>
<%-- <script src="<%=request.getContextPath()%>/ui/js/customPaginate.js"></script> --%>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>

<%@include file="/ui/jsp/includes/header.jspf"%>

<script type="text/javascript">
	function viewStudent(studentId) {
		$('#studentId').val(studentId);
		$('#viewStudentForm').attr('action', 'viewExistingStudent.html');
		$('#viewStudentForm').submit();
	}
	function addNewStudent() {
		$('#viewStudentForm').attr('action', 'viewNewStudent.html');
		$('#viewStudentForm').submit();
	}
	function viewStudentDetails(studentId) {
		$('#studentId').val(studentId);
		$('#viewStudentForm').attr('action', 'viewStudentDetails.html');
		$('#viewStudentForm').submit();
	}
	function printStudentList() {
		window.open('printStudentList.html');
	}
</script>

<div class="hero-unit secondary_container">
	<div id="table-subject-header">
		View Student List
	</div>
	<hr>
	
	<div class="row-fluid">
		<form method="POST" id="viewStudentForm">

			<div class="addnew_button">
				<input type="button" title="Add New Student" value="Add New" onclick="javascript:addNewStudent()" class="btn btn-primary">
				<input type="button" title="Display in a Print-friendly Format" value="Print" onclick="javascript:printStudentList()" class="btn btn-primary">
				
			</div>

			<div class="span10">
				<table id='dataTableList' class="table table-striped table-bordered">
					<thead>
						<tr>
							<th width="8%">Action</th>
							<th>Student First</th>
							<th>Student Last</th>
							<th>N Number</th>
							<th>E-mail Address</th>
							<th>Major</th>
							<th>Year Graduated</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="student" items="${studentList}">
							<tr class="paginationList">
								<td><a
									href="javascript:viewStudentDetails('${student.studentId}')"><img
										src="<%=request.getContextPath()%>/ui/images/view.gif"
										title="View" /></a> 
										
										<c:if test="${roleId==1 || (roleId == 2 && loginId == student.thesisChairId) || roleId==3}">
										<a href="javascript:viewStudent('${student.studentId}')"><img
											src="<%=request.getContextPath()%>/ui/images/edit.gif"
											 title="Edit"></a>
											 
									</c:if> </td>
								<td>${student.firstName}</td>
								<td>${student.lastName}</td>
								<td>${student.nnumber}</td>
								<td>${student.email}</td>
								<td>${student.major}</td>
								<td>${student.yearGraduated}</td>
							</tr>
							
						</c:forEach>
						
					</tbody>
				</table>

				<div class="pagination"></div>
			</div>
			<input type="hidden" id="studentId" name="studentId" value=""/>
		</form>
	</div>
	</div>
	<%@include file="/ui/jsp/includes/footer.jspf"%>